[var:'imagepath'=(action_param:'img')]

[if:(var:'imagepath')==''][abort][/if]
[if:(File_Exists:(var:'imagepath'))!='True'][abort][/if]

<?LassoScript
	var: 'maxwidth' = 80;
	var: 'maxheight' = 80;
	
	if: ($imagepath >> '.jpg');
		content_type: 'image/jpeg';
	else: ($imagepath >> '.jpeg');
		content_type: 'image/jpeg';
	else: ($imagepath >> '.gif');
		content_type: 'image/gif';
	else: ($imagepath >> '.png');
		content_type: 'image/png';
	else;
		fail: -1, 'error : Unkown Image Type';
	/if;
	
	var: 'image' = (image: $imagepath);
	
	// Scale image
	if: ($image->width > $image->height) && ($image->width > $maxwidth);
		$image->(scale: -width=$maxwidth, -thumbnail);
	else: ($image->height > $maxheight);
		$image->(scale: -height=$maxheight, -thumbnail);
	/if;
	
	//$image->(Annotate:'your text here', -Left=10, -Top=20, -Color='#777777', -Aliased, -Size=14);
	
	// Serve image
	$__html_reply__ = $image->data;
	abort;
?>